package com.kust.smarthome.web.socketserver;

import java.net.Socket;
import java.util.HashMap;
import java.util.Iterator;

public class ManageClientThread {

    public static HashMap<String,Socket> hm=new HashMap<String,Socket>();

    //向hm中添加一个客户端通讯线程
    public static  void addClientThread(String uid,Socket socket)
    {
        hm.put(uid, socket);
    }

    public static Socket getClientThread(String uid)
    {
        return (Socket) hm.get(uid);
    }

    //返回当前在线的人的情况
    public static String getAllOnLineUserid()
    {
        //使用迭代器完成
        Iterator it=hm.keySet().iterator();
        String res="";
        while(it.hasNext())
        {
            res+=it.next().toString()+" ";
        }
        return res;
    }
}
